<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.saturn.auth.User"%>
<%@page import="com.saturn.sldb.Discussion"%>
<%@page import="com.saturn.app.utils.DateUtils"%>
<%@page import="com.saturn.auth.Organization"%>
<%@page import="java.util.*"%>
	<%
	User user = (User)session.getAttribute("authUser");
	String userId = user.getId();
	Organization organizationUser = Organization.getOneOrganizationByUser(userId);
	String name = organizationUser.getName();
	List organizations = Organization.getOrganizationByUser(user.getId());
	String department = "";
	if (organizations != null && !organizations.isEmpty()) {
		department = ((Organization)organizations.get(0)).getName();
	}
	%>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加紧急救助低保</title>
<%@ include file="/app/includes/header.jsp"%>
<style type="text/css">
<!--
.STYLE1 {
	font-size: 24px;
	font-weight: bold;
}
-->
	input {border:none;}
	.table_1{border-right:1px solid black; border-top:1px solid black}
	.table_1 td{border-left:1px solid black; border-bottom:1px solid black;}
	body{font-size:12px;}
</style>
<script> 
function submit(){ 
	if(editForm.name.value==""){ 
		alert("请输入姓名"); 
		}else if(editForm.sex.value==""){ 
		alert("请输入性别"); 
		}else if(editForm.identify.value==""){ 
		alert("请输入身份证号"); 
		}else if(editForm.home.value==""){ 
		alert("请输入家庭人口"); 
		}else if(editForm.money.value==""){ 
		alert("请输入审批金额"); 
		}else{
			var identify = $("#identify").val();
			//*********家庭编号根据低保对象表中获取存储到数据库中*********BEGIN
			$.ajax({
				type : 'post',
				async : false,
				data : { "identify": identify},
				url : "<%=request.getContextPath()%>/app/sldb/emergency/apply/checkHomeNumberAction.action",
				success : function(data, textStatus, jqXHR){
					//console.info(data);
					if(data.homeNumber!=null){
						$("#homeNumber").val(data.homeNumber);
					}
				},
				dataType : 'json'
			});
			//*********家庭编号根据低保对象表中获取存储到数据库中*********END

			//*******************如不存在则返回“此申报信息为非低保户“信息字样******BEGIN
			var safeWay = $("input[name='safeWay']:checked").val();
			if(safeWay=="低保对象"){
				if(identify==""||identify==null){
					alert("身份证号不能为空");
					return;
				}
				$.post(
					"<%=request.getContextPath()%>/app/sldb/emergency/apply/checkSafeWayAction.action",
					{ "identify": identify},
					function(data){
						if(data.count==0){
							alert("此申报信息为非低保户");
							return;
						}else{
							$('#editForm').submit();
						}
					}, 
					"json");
			}else{
	$('#editForm').submit();
		}
		}
} 
</script> 
<!-- START JS为radio赋值 -->
<script language="javascript" type="text/javascript">
	$(document).ready(function() {
		//救助类型
		var peopleTypeVO = "${discussion.peopleType}";
		if(document.getElementById("geren").value == peopleTypeVO){
			$("input[id='geren']").attr("checked",true);
		} else if(document.getElementById("jiating").value == peopleTypeVO){
			$("input[id='jiating']").attr("checked",true);
		}

		//城镇类型
		var accountTypeVO = "${discussion.accountType}";
		if(document.getElementById("nongchun").value == accountTypeVO){
			$("input[id='nongchun']").attr("checked",true);
		} else if(document.getElementById("chengshi").value == accountTypeVO){
			$("input[id='chengshi']").attr("checked",true);
		}
		
		//户籍属地
		var registrationVO = "${discussion.registration}";
		if(document.getElementById("bendi").value == registrationVO){
			$("input[id='bendi']").attr("checked",true);
		} else if(document.getElementById("feibendi").value == registrationVO){
			$("input[id='feibendi']").attr("checked",true);
		}
		//申请事由
		var applyCauseVO = "${discussion.applyCause}";
		if(document.getElementById("hz").value == applyCauseVO){
			$("input[id='hz']").attr("checked",true);
		} else if(document.getElementById("jt").value == applyCauseVO){
			$("input[id='jt']").attr("checked",true);
		}else if(document.getElementById("tf").value == applyCauseVO){
			$("input[id='tf']").attr("checked",true);
		}else if(document.getElementById("kj").value == applyCauseVO){
			$("input[id='kj']").attr("checked",true);
		}else if(document.getElementById("zc").value == applyCauseVO){
			$("input[id='zc']").attr("checked",true);
		}else if(document.getElementById("qt").value == applyCauseVO){
			$("input[id='qt']").attr("checked",true);
		}
		
		//救助方式
		var safeWayVO = "${discussion.safeWay}";
		if(document.getElementById("dibao").value == safeWayVO){
			$("input[id='dibao']").attr("checked",true);
		} else if(document.getElementById("feidibao").value == safeWayVO){
			$("input[id='feidibao']").attr("checked",true);
		}
	});
	

</script>
<script type="text/javascript">
function showPhoto(){
	var p = '${discussion.files}';
	var str= new Array();   
	str=p.split(";"); 
	var files = $("#filess").html();
	for (i=0;i<str.length ;i++ )   
	{   
		if(str[i]!=null&&str[i]!="")
		files+="<a href=\""+str[i]+"\" target=\"_blank\"><img src=\""+str[i]+"\" width=100px; height=100px;/></a>&nbsp;";
	}   
	$("#filess").html(files);
}
$(function() {
	showPhoto();
});
</script>
<!-- END JS为radio赋值 -->
</head>
<body>
	<form id="editForm" name="editForm" action="<%=request.getContextPath()%>/app/sldb/discussion/apply/updateDiscussion.action" method="post">
		<input type="hidden" name="type1" value="auto" />
		<input id="createTime" name="createTime" type="hidden" value="${discussion.createTime}"></input>
			<input id="creater" name="creater" type="hidden" value="${discussion.creater}"></input>
			<input id="createrName" name="createrName" type="hidden" value="${discussion.createrName}"></input>
			<input id="createrDepartment" name="createrDepartment"  type="hidden" value="${discussion.createrDepartment}"></input>
			<input id="state" name="state" type="hidden" value="${discussion.state}"></input>
			<input id="inputType" name="inputType" type="hidden" value="${discussion.inputType}"></input>
			<input id="homeNumber" name="homeNumber" type="hidden" value="${discussion.homeNumber}"></input>
			<input id="type" name="type" type="hidden" value="${discussion.type}"></input>
			<input id="subject" name="subject" type="hidden" value="${discussion.subject}"></input>
			<input type="hidden" id="id" name="id" value="${discussion.id}" />
			<input id="files" name="files" type="hidden" value="${discussion.files}"></input>
			<input type="hidden" id="remarks" name="remarks" value="${discussion.remarks}" />

		<script language="javascript" type="text/javascript">
				function ClearForm() {
					document.getElementById('name').value = "";
                    document.getElementById('sex').value = "";
                    document.getElementById('identify').value =  "";
                    document.getElementById('address').value = "";
                    document.getElementById('picture').src = ""; 
                      return true;
				}
		</script>
		<a href="#" onclick="submit()" class="easyui-linkbutton" id="Button1">提   交</a>
		<a href="#" onclick="ClearForm()" class="easyui-linkbutton" id="Button2">清   空</a>
		<p>
<center>
<label style="font-size:24px">临时救助“一事一议”事项流程单</label>
<br> 
<br>
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_1">
  <tr>
      <td height="30" colspan="7" align="right">
    	编号： <input type="text" id="numberNO" name="numberNO" value="${discussion.numberNO }" style="border-top-style:none;border-left-style:none;border-right-style:none;border-bottom-style:none;"/></span>
    	<input id="ynumberNO" type="hidden" value="${discussion.numberNO}" />
    </td>
  </tr>
  <tr>
    <td height="20" colspan="7" bgcolor="#BFBFBF"><strong>申请人基本情况：</strong></td>
    </tr>
  <tr>
    <td width="104" height="37"><div align="center">户主或本人姓名</div></td>
    <td width="116"><input id="name" type="text" name="name" size="9" value="${discussion.name }"/></td>
    <td width="111"><div align="center">性别</div></td>
    <td width="73"><input id="sex" type="text" name="sex" size="9" value="${discussion.sex }"/></td>
    <td width="69"><div align="center">家庭人口</div></td>
    <td width="66"><input id="home" type="text" name="home" size="9" value="${discussion.home }"/></td>
    <td rowspan="3"> &nbsp;&nbsp;&nbsp;上传照片</td>
    </tr>
  <tr>
    <td height="33"><div align="center">
      <p>公民身份证号</p>
      </div></td>
    <td colspan="5" align="left"><input id="identify" type="text" name="identify" size="18" value="${discussion.identify }"/></td>
    </tr>
  
  <tr>
    <td height="50"><div align="center">对象类别</div></td>
    <td colspan="5" align="left">
      <span class="STYLE2"><input type="radio" id="geren" name="peopleType" checked="checked" value="个人对象" />个人对象&nbsp;&nbsp;<input type="radio" id="bendi" name="registration" checked="checked" value="本地户籍" />本地户籍&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="nongchun" name="accountType" checked="checked" value="农村居民" />农村居民&nbsp;&nbsp;<input id="dibao" type="radio" name="safeWay" checked="checked" value="低保对象" />低保对象</span><br>
      <span class="STYLE2"><input type="radio" id="jiating" name="peopleType" value="家庭对象" />家庭对象&nbsp;&nbsp;<input type="radio" id="feibendi"  name="registration" value="非本地户籍" />非本地户籍 &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="chengshi" name="accountType" value="城市居民" />城市居民&nbsp;&nbsp;<input type="radio" id="feidibao"  name="safeWay" value="非低保对象" />非低保对象</span></td>
    </tr>
 
  <tr>
    <td height="55"><div align="center">申请事由</div></td>
    <td height="55" colspan="6" align="left"><span class="STYLE2"><input type="radio" id="hz" name="applyCause" value="火灾" />火灾&nbsp;<input type="radio" id="jt" name="applyCause" value="交通事故" />交通事故&nbsp;<input type="radio" id="tf" name="applyCause"  value="突发重大疾病" />突发重大疾病<input type="radio" id="kj" name="applyCause" value="困境低保" />困境低保&nbsp;<input type="radio" id="zc" name="applyCause" value="支出型困难" />支出型困难&nbsp;<input type="radio" id="qt" name="applyCause" value="其他特殊困难" />其他特殊困难</span><br><br>&nbsp;病种描述：<input type="text" name="causeDesc" id="causeDesc" size="60" value="${discussion.causeDesc }" style="border-bottom: 1px solid;"/></td>
  </tr>
  
  <tr>
    <td height="100"><div align="center">启动“一事
    	<br>一议”理由</div></td>
    <td height="100" colspan="6" align="left"><textarea id="startCause" name="startCause" style="height:80px; width:500px;border:none;">${discussion.startCause }</textarea>
    </td>
  </tr>
   <tr>
    <td height="28"><div align="center">审批人</div></td>
    <td colspan="2" align="left"><input id="audit" type="text" name="audit" size="11" value="${discussion.audit }"/></td>
    <td colspan="3"><div align="center">审批金额</div></td>
    <td align="left"><input id="money" type="text" name="money" size="11" value="${discussion.money }"/></td>
  </tr>
  <tr>
    <td height="20" colspan="7" bgcolor="#BFBFBF" align="left"><strong>附件：</strong></td>
    </tr>
  <tr>
    <td height="99" colspan="7" align="left">&nbsp;<div align="left"  id="filess"></div></td>
    </tr>
</table>
</center>
<input type="hidden" id="photo" name="photo" value="${discussion.photo }"/>
</form>
<script type="text/javascript">
	$(document).ready(function() {
		
		//*******************模态窗口形式统计当前低保户本年的申报次数、总金额、年份、姓名、身份证号信息******BEGIN
		$("#identify").blur(function(){
			var identify = $("#identify").val();
			if(identify==""||identify==null){
				alert("身份证号不能为空");
				return;
			}
			//当前申请人员保障信息统计
            window.open ('<%=request.getContextPath()%>/app/sldb/discussion/apply/statistics.jsp?cardNo='+identify,'打印页面','height=300,width=300,top=50,left=300,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
		});
		//*******************模态窗口形式统计当前低保户本年的申报次数、总金额、年份、姓名、身份证号信息******END
		
		});
</script>
</body>
</html>
